#include "mainwindow.h"
#include "receiver.h"
#include "sender.h"
#include <QDebug>
#include <QPushButton>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
//    this->setFixedSize(400, 300);

//    //  创建对象
//    Sender *sender = new Sender;
//    Receiver *receiver = new Receiver;
//    // 连接
//    connect(sender, &Sender::exit,
//            receiver, &Receiver::handleExit);
//    // 发出信号,最终会调用Receiver:handleExit函数
//    qDebug() << emit sender->exit(10, 20);
//    // 销毁对象
//    delete sender;
//    delete receiver;

    QPushButton *btn = new QPushButton("按钮", this);
    this->setFixedSize(100, 30);
    // lambda处理槽函数
//    connect(btn, &QPushButton::clicked,[](int a) {
//        qDebug() << "点击了按钮";
//    });
    // 自定义槽函数
    connect(btn, &QPushButton::clicked,
            this, &MainWindow::handleExit);

}

void MainWindow::handleExit(int a) {
    qDebug() << "MainWindow::handleExit(int a)" << a << endl;
}

MainWindow::~MainWindow()
{
}

